home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
53696
/
53696.xpi
/
chrome
/
content
/
bin_category.js
next >
Wrap
Text File
|
2009-12-15
|
3KB
|
112 lines
String.prototype.ltrim = function String$ltrim() { var re = /\s*((\S+\s*)*)/; return this.replace(re, "$1"); }
String.prototype.rtrim = function String$rtrim() { var re = /((\s*\S+)*)\s*/; return this.replace(re, "$1"); }
String.prototype.trim = function String$trim() { return this.ltrim(this.rtrim()); }
function glideBinCategoryDialog_GetParentWindow() {
if (window.opener) {
if (window.opener.opener) {
return window.opener.opener;
} else {
return window.opener;
}
}
}
var prompt = null;
var glideSession = null;
var invokeService = null;
var ENDPOINT_FS = null;
var categoryId = null;
function refreshList() {
var ml = document.getElementById("glide-bin-categories-list");
ml.removeAllItems();
ml.appendItem("(None)", "NONE");
ml.appendItem("(New Category...)", "NEW");
invokeService(ENDPOINT_FS, "getbincategories", false,
{ token: glideSession.token },
function(d) {
if (!d.success) {
alert(d.message);
return;
}
var items = d.items;
var found = false;
for (var i = 0; i < items.length; i++) {
ml.appendItem(items[i].name, items[i].categoryId.toLowerCase());
}
ml.value = categoryId;
if (null == ml.selectedItem) {
ml.selectedIndex = 0;
categoryId = "NONE";
}
});
}
function glideBinCategoryDialog_Load() {
prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
glideSession = window.arguments[0].inn.glideSession;
invokeService = window.arguments[0].inn.invokeService;
ENDPOINT_FS = window.arguments[0].inn.ENDPOINT_FS;
categoryId = window.arguments[0].inn.categoryId.toLowerCase();
refreshList();
}
function glideBinCategoryDialog_Selected(who) {
if ("NEW" == who.value) {
while (true) {
var name = { value: "" };
if (!prompt.prompt(null, "New Bin Category", "Please enter the name of the new category:", name, "", {})) {
document.getElementById("glide-bin-categories-list").selectedIndex = 0;
categoryId = "NONE";
return;
}
name.value = name.value.trim();
if ("" == name.value) {
alert("Please enter the category name");
continue;
}
break;
}
invokeService(ENDPOINT_FS, "addbincategory", false,
{ token: glideSession.token, name: name.value },
function(d) {
if (!d.success) {
alert(d.message);
return;
}
categoryId = d.value;
document.getElementById("glide-bin-category-dialog").acceptDialog();
});
return;
}
categoryId = who.value;
}
function glideBinCategoryDialog_Accept() {
window.arguments[0].out = categoryId;
return true;
}